package net.cyndeline.systems.logging

import scala.collection.mutable.Buffer
import scala.collection.mutable.ArrayBuffer
import net.cyndeline.entitySystem.EntityRef
import net.cyndeline.entitySystem.Component

/**
 * Used to quickly retrieve entity components and their content 
 * in String form.
 */
trait ComponentRetriever {
  
  /** Retrieves the component content of an entity in string form. */
  def getComponentStringBuffer(e: EntityRef) = {
    val componentBag = e.iterateComponents
    componentPrintBuffer(componentBag)
  }
  
  /** Create s a String buffer of the components. */
  private def componentPrintBuffer(componentBag: Iterator[Component]) = {
    val buffer = new ArrayBuffer[String]()
    var nl = sys.props("line.separator")
      
    for (component <- componentBag) {         
      buffer += nl + component.toString
    }
    
    buffer
  }
}